Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
web-encoding
Advanced tools
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The web-encoding package provides a polyfill for the TextEncoder and TextDecoder interfaces, which are part of the Encoding Living Standard. These interfaces allow for high-performance encoding and decoding of text in various character encodings, primarily UTF-8.
Text Encoding
This feature allows you to encode a JavaScript string into a Uint8Array of bytes using UTF-8 encoding. It is useful for preparing text data for network transmission or storage.
const { TextEncoder } = require('web-encoding');
const encoder = new TextEncoder();
const encoded = encoder.encode('Hello, world!');
console.log(encoded);
Text Decoding
This feature enables decoding of a Uint8Array of bytes into a JavaScript string using UTF-8 or other supported character encodings. It is essential for reading text data received from a network or read from binary storage.
const { TextDecoder } = require('web-encoding');
const decoder = new TextDecoder('utf-8');
const decoded = decoder.decode(new Uint8Array([72, 101, 108, 108, 111]));
console.log(decoded);
The text-encoding package also provides TextEncoder and TextDecoder polyfills. It supports a wider range of encodings than web-encoding, making it suitable for applications that need to handle various character sets beyond UTF-8.
Similar to web-encoding, fast-text-encoding offers TextEncoder and TextDecoder implementations. It focuses on performance optimizations for UTF-8 encoding and decoding, making it a good choice for performance-critical applications that primarily deal with UTF-8 data.
This package provides TextEncoder and TextDecoder Encoding Standard
APIs in a universal package. In the browsers it just exposes existing globals,
in nodejs it exposes globals in newer node versions and ones from util
module
in older versions, and in the React Native environments it exposes these from
the @zxing/text-encoding
polyfill (installed as an optional dependency).
Package also works as ES module and CommonJS module.
import { TextEncoder, TextDecoder } from "web-encoding"
npm install web-encoding
FAQs
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The npm package web-encoding receives a total of 1,725,183 weekly downloads. As such, web-encoding popularity was classified as popular.
We found that web-encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.